
trait Printable {
    fn print(&self);
}

struct Person<'a> {
    name: &'a str,
}

impl<'a> Printable for Person<'a> {
    fn print(&self) {
        println!("person name: {}", self.name);
    }
}

struct Animal {
    name: String,
}

impl Printable for Animal {
    fn print(&self) {
        println!("animal name: {}", self.name);
    }
}

fn main() {
    let person = Person {
        name: "zhangsan",
    };

    let animal = Animal {
        name: "cat".to_string(),
    };

    print(&person);
    print(&animal);
}

fn print(s: &impl Printable) {
    s.print();
}
